package com.qf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.mapper.CityMapper;
import com.qf.pojo.City;
import com.qf.service.CityService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CityServiceImpl implements CityService {

    @Resource
    private CityMapper cityMapper;
    @Override
    public PageInfo<City> select(int p, int size) {
        PageHelper.startPage(p,size);
        List<City> all = cityMapper.select();
        PageInfo<City> cityPageInfo = new PageInfo<>(all);
        return cityPageInfo ;
    }

    @Override
    public City add(City city) {
        int i = cityMapper.add(city);
        return city;

    }

    @Override
    public int delete(int id) {
        int delete = cityMapper.delete(id);
        return delete;
    }

    @Override
    public City update(City city) {
        int  update = cityMapper.update(city);
        return city;
    }

    @Override
    public List<City> selectOne(int pid) {
        List<City> cities = cityMapper.selectOne(pid);
        return cities;
    }

    @Override
    public City selectById(int id) {
        City cities = cityMapper.selectById(id);
        return cities;
    }
}
